<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>车辆检测报告 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">支付表号</div>
                    <div class="field">
                        <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox" id="searchPrjTypCdId">
                    <div class="label">项目类型</div>
                    <div class="field">
                        <select name="prjTypCd"  id="prjTypCd" >
                            <option value="  " selected="selected">--请选择--</option>
                            <c:forEach items="${projectTypeList}" var="opt">
                                <option value="${opt.key}">${opt.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox" id="searchBizTypCdId">
                    <div class="label">业务模式</div>
                    <div class="field">
                        <select name="bizTypCd"  id="bizTypCd"  >
                            <option value="  " selected="selected">--请选择--</option>
                            <c:forEach items="${bizTypeList}" var="opt">
                                <option value="${opt.key}">${opt.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn"  class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,callback=null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/project/prjprdpayschm/initVehDetectionList.do',
            method: 'get',
            columns: [
                { display: '支付表号', name: 'paySchNo', minWidth: 200,align:'left',
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        h='<a href="javascript:detailBtn(';
                        h+="'"+rowdata.prjPrdDtlId+"',";
                        h+="'"+rowdata.id+"',";
                        h+="'"+rowdata.prjPrdId+"',";
                        h+="'"+rowdata.prjId+"'";
                        h+=')">'+value+'</a>'
                        return h;
                    },
                    enabledSort:true},
                {display: '业务模式', name: 'bizTypCdNm', minWidth: 140 , enabledSort:true},
                {display: '客户名称', name: 'cstNm', minWidth: 140,align:'center', enabledSort:true},
                {display: '项目类型', name: 'prjTypCdNm', width: 150, enabledSort:true},
                {display: '事业部', name: 'buOrgCdNm', width: 100, enabledSort:true},
                {display: '省公司', name: 'prOrgCdNm', width: 100 , enabledSort:true},
                {display: '分公司', name: 'cyOrgCdNm', width: 100 , enabledSort:true},
                {display: '车检费比例(%)', name: 'carPct', width: 100, enabledSort:true},
                {display: '车检费金额(元)', name: 'caijf', width: 100, enabledSort:true},
                {display: '放款状态', name: 'payStsCdNm', width: 80, align: 'center', enabledSort: false},
                getGridOperColumnContent()
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            //isScroll: false,
            checkbox: true,
            rownumbers: true,
            delayLoad:false,
            allowUnSelectRow: true,
            alternatingRow: false
            /* onRenderComplete: function () {
             iframeResize ();
             } */
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function(event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            data["crtTm"] = $("#crtTm").val();
            for (name in data){
                grid.setParm(name,data[name]);
            };
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });

        callback = function () {
            grid.reload();
        };
    });

    //Grid操作列
    function getGridOperColumnContent(){
        var data = {
            display: '操作',
            isSort: false,
            width: 180,
            render: function (rowdata, rowindex, value){
                var h = "";
                if(rowdata.payStsCd == 2 || rowdata.payStsCd == null){
                    h+=" ";
                }else {
                    if(rowdata.prjTypCd == 'ESCJYD' || rowdata.prjTypCd == 'ESC' || rowdata.prjTypCd == 'CDDYW' || rowdata.prjTypCd == 'CDDYWUL' || rowdata.prjTypCd == 'OWNJYD'){
                        h+='<a class="sq-button-hasicon" href="javascript:showPdf(';
                        h+="'"+rowdata.id+"'";
                        h+=")\"></i>二手车检测报告</a>";
                    }else {
                        h+='<a class="sq-button-hasicon" href="javascript:showPdfNew(';
                        h+="'"+rowdata.id+"'";
                        h+=")\"></i>新车检测报告</a>";
                    }
                }
                return h;
            }
        }
        return data;
    }


    //查看二手车检测报告PDF文件
    function showPdf(_id){
        $.post(
            "<%=path %>/project/prjbscinfo/createPdf.do",
            {id:_id},
            function(msg){
                if(msg.success == 1){
                    window.open(msg.data);
                }else{
                    parent.ligerDialogSuc("生成检测报告失败！！！");
                }
            },
            "json"
        );
    }


    //查看新车检测报告PDF文件
    function showPdfNew(_id){
        $.post(
            "<%=path %>/project/prjbscinfo/createPdfNewCar.do",
            {id:_id},
            function(msg){
                if(msg.success == 1){
                    window.open(msg.data);
                }else{
                    parent.ligerDialogSuc("生成检测报告失败！！！");
                }
            },
            "json"
        );
    }

    function detailBtn(prjPrdDtlId,id,prjPrdId,prjId){
        var editFlag = true;
        Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag='+editFlag);
    }

</script>

</body>
</html>
